/*
 * This file (AkStampBrush.java) is protected by the GNU GPL licence (v2). 
 * Please read the license.txt attached for further informations. 
 * 
 */

package alkwarel.objects;

/**
 * @author Xavier Gouchet
 * 
 */
public abstract class AkStampBrush extends AkBrush {

	/**
	 * Standard Constructor.
	 * 
	 * @param id
	 *            the object's id
	 * @param name
	 *            the object's name
	 */
	public AkStampBrush(int id, String name) {
		super(id, name);
	}

	/**
	 * @see alkwarel.objects.AkBrush#DrawStroke(alkwarel.objects.AkArtspace,
	 *      float, float, float, float)
	 */
	public final boolean DrawStroke(AkArtspace a, float srcx, float srcy,
			float destx, float desty) {
		float dist = (float) Math.sqrt(((destx - srcx) * (destx - srcx))
				+ ((desty - srcy) * (desty - srcy)));
		if (dist > 0) {
			float step = 2; // TODO externalise parameter
			for (float i = 0; i <= dist; i += step) {
				float t = i / dist;
				float curx = (t * destx) + ((1 - t) * srcx);
				float cury = (t * desty) + ((1 - t) * srcy);
				this.DrawStamp(a, curx, cury);
			}
		}
		return true;
	}

	/**
	 * Draws the stamp at the given position
	 * @param a the artspace on which the brush is applied
	 * @param posx the x position of the stamp
	 * @param posy the y position of the stamp
	 */
	public abstract void DrawStamp(AkArtspace a, float posx, float posy);

}
